home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / comm / bbs / FList_211.lha / FList / Bonus / AmNSpam.Rexx next >
OS/2 REXX Batch file  |  1997-03-14  |  6KB  |  165 lines

  1. /**/
  2. /* Am N' Spam - (C) S.Gillibrand 1996 - Digital Design Production           */
  3. /*                                                                          */
  4. /* Usage:                                                                   */
  5. /*                                                                          */
  6. /* amnspam [cd device]   [output path]   [default access]   [default flags] */
  7. /*         cd0:          file:cd/aminet/ 10                 --------        */
  8. /*                                                                          */
  9. /**/
  10. options failat 50
  11. say 'H'
  12. say 'Am N'' Spam - (c) S.Gillibrand 1996 - Digital Design Production'
  13. say 'FList CD [Aminet] List compiler!'
  14. say ''
  15. arg cddev' 'topath' 'defacc' 'deflag
  16. if compress(cddev)=""|compress(cddev)="?" then do
  17.     say 'amnspam [cd device]  [output path]    [default access]  [default flags]'
  18.     say '        cd0:         file:cd/aminet/  10                --------       '
  19.     say ''
  20.     exit
  21. end
  22. if right(topath,1)='/' then topath=left(topath,length(topath)-1)
  23. address command 'info 'cddev' >ram:cdinf'
  24. call open(cdinf,'ram:cdinf','r')
  25. do 3;dummy=readln(cdinf);end
  26. volnam=substr(readln(cdinf),53)':'
  27. call close(cdinf)
  28. say 'Building directory information from ['cddev']...'
  29. dte="961219"
  30. if ~open(inc,cddev'aminet/tree','r') then do
  31.     say 'There is NO Aminet CD located in the device ['cddev']!'
  32.     say ''
  33.     exit
  34. end
  35. series=substr(volnam,7,length(volnam)-7)
  36. say 'Detected Aminet Series 'series
  37. do 2;say '';end
  38. topath=topath||series
  39. if ~exists(topath) then address command 'makedir "'topath'" >NIL:'
  40. if ~exists(topath) then do
  41.     say 'ACannot access or create ['topath']!'
  42.     say ''
  43.     exit
  44. end
  45. topath=topath'/'
  46. call open(acfgo,topath'_areas.cfg','w')
  47. call open(_acfgo,topath'__areas.cfg','w')
  48. call writeln(_acfgo,'#')
  49. call writeln(_acfgo,'# FList CDRom Areas Config')
  50. call writeln(_acfgo,'# The Syntax Is As Follows...')
  51. call writeln(_acfgo,'#')
  52. call writeln(_acfgo,'# The First Line Is The Number Of Areas You Have.')
  53. call writeln(_acfgo,'#')
  54. call writeln(_acfgo,'# The Name Of The Area As You Wish It To Appear Inside FList')
  55. call writeln(_acfgo,'# The Path To The List Of Files (As Generated By An External FList Cd Compiler)')
  56. call writeln(_acfgo,'# [Optional] The Global Path To Where All The Files In The List Area Are Located.')
  57. call writeln(_acfgo,'# The Minimum Access Level Required To Access The Area.')
  58. call writeln(_acfgo,'# The Minimum Flags Required To Access The Area.')
  59. call writeln(_acfgo,'#')
  60. call open(rams,'ram:sjit','w')
  61. areas=0
  62. do until eof(inc)
  63.     data=readln(inc)
  64.     if pos('/',left(data,12))=0|pos('info/',left(data,12))>0 then iterate
  65.     if compress(data)="" then iterate
  66.     areas=areas+1
  67.     dir=compress(left(data,12))
  68.     say 'AStoring & Creating from ['dir']...'
  69.     desc.dir=right(data,length(data)-13)
  70.     call writeln(rams,dir)
  71.     if ~exists(topath||dir) then do
  72.         golp=left(dir,pos('/',dir)-1)
  73.         if ~exists(topath||golp) then address command 'makedir "'topath||golp'" >NIL:'
  74.         address command 'makedir "'topath||dir'" >NIL:'
  75.     end
  76. end
  77. call close(inc)
  78. call close(rams)
  79. say ''
  80. say '['areas'] areas found.'
  81. say ''
  82. say 'Adding CDRom information to BBS:Configs/FList.CDROM...'
  83. if ~open(flcdr,'bbs:configs/flist.cdrom','a') then do
  84.     call open(flcdr,'bbs:configs/flist.cdrom','w')
  85.     call writeln(flcdr,'#')
  86.     call writeln(flcdr,'# FList CDRom Config File')
  87.     call writeln(flcdr,'#')
  88.     call writeln(flcdr,'# The Syntax Is As Follows:')
  89.     call writeln(flcdr,'#')
  90.     call writeln(flcdr,'# The Full Title Of The Cd As You Want It To Appear In FList.')
  91.     call writeln(flcdr,'# The Device Name For The Cd (DON''T USE CD0/1/2/etc.:!).')
  92.     call writeln(flcdr,'# The Path To The Config File For The Areas Of The CD-Rom.')
  93.     call writeln(flcdr,'# [Optional] Path To An ANSI File That Will Be Used Instead Of Listing Areas.')
  94.     call writeln(flcdr,'# Minimum Access Level Needed To Access This CDRom.')
  95.     call writeln(flcdr,'# Minimum Flag Requirements Needed To Access This CDRom.')
  96.     call writeln(flcdr,'#')
  97. end
  98. call writeln(flcdr,caseconvert(left(volnam,6))' 'left(right(volnam,3),2)' - Definitive collection of Amiga files')
  99. call writeln(flcdr,volnam)
  100. call writeln(flcdr,topath'Areas.Cfg')
  101. call writeln(flcdr,'')
  102. call writeln(flcdr,defacc)
  103. call writeln(flcdr,deflag)
  104. call close(flcdr)
  105. say ''
  106. say 'Compiling FList files.bbs format files...'
  107. say ''
  108. call open(In,'ram:sjit','r')
  109. do until eof(in)
  110.     dir=readln(in)
  111.     if compress(Dir)="" then leave
  112.     mas=dir
  113.     dir=cddev'aminet/'dir
  114.     call writech(stdout,'AWorking on ['left(mas,12)']')
  115.     call writech(stdout,'.')
  116.     if ~open(ni,dir'/index','r') then do
  117.         say ': [NO INDEX FILE]'
  118.         say ''
  119.         areas=areas-1
  120.     end
  121.     else do
  122.         call writeln(acfgo,desc.mas)
  123.         call writeln(acfgo,topath||mas'/files.bbs')
  124.         call writeln(acfgo,volnam'aminet/'mas'/')
  125.         call writeln(acfgo,defacc)
  126.         call writeln(acfgo,deflag)
  127.         call writech(stdout,'.')
  128.         call open(Out,topath||mas'/files.bbs','w')
  129.         call writech(stdout,'.')
  130.         do until eof(ni)
  131.             data=readln(ni)
  132.             if eof(ni) then leave
  133.             if left(data,1)="|"|compress(data)="" then iterate
  134.             fnam=left(data,18)
  135.             fsiz=compress(substr(data,31,3))*1024
  136.             if substr(data,34,1)="M" then fsiz=left(fsiz,1)||right(fsiz,1)*102400
  137.             call writeln(out,left(fnam,23)' 'right(fsiz,7)' 'dte' 'right(data,length(data)-39))
  138.         end
  139.         call close(out)
  140.         say '.'
  141.     end
  142.     call close(ni)
  143. end
  144. call close(in)
  145. call close(acfgo)
  146. say ''
  147. say 'Finished buttering!'
  148. call writeln(_acfgo,areas)
  149. call close(_acfgo)
  150. address command 'join "'topath'__areas.cfg" "'topath'_areas.cfg" as="'topath'areas.cfg"'
  151. address command 'delete "'topath'_areas.cfg'" quiet'
  152. address command 'delete "'topath'__areas.cfg'" quiet'
  153. say '['areas'] areas found containing valid INDEX files.'
  154. say ''
  155. exit
  156.  
  157. CaseConvert:
  158. arg conv_str
  159. conv_str=translate(CONV_STR,Xrange('a','z'),Xrange('A','Z')) ; tmp=''
  160. do a=1 to words(CONV_STR)
  161.     tmp=tmp||upper(left(word(CONV_STR,A),1))substr(word(CONV_STR,A),2)' '
  162. end
  163. CONV_STR=left(tmp,length(tmp)-1)
  164. return(CONV_STR)
  165.